home *** CD-ROM | disk | FTP | other *** search
- /*
- ** PGP5GUI - A GUI using Magic User Interface v3.8
- **
- ** Copyright 23-JUNE-1998 by Stefan Zakarias, All Rights Reserved.
- **
- ** This source code is released as FREEWARE - Use it for whatever you like,
- ** as long as NO financial reward is gained by you for such usage.
- **
- ** If you use any parts of the this source code for anything, give ME credit
- ** wherever credit is due, please ;-)
- */
-
- /*
- ****************************************************************************************
- **
- ** PGP5Main.c
- **
- ****************************************************************************************
- */
-
- /* Libraries */
- #include <libraries/mui.h>
- #include <libraries/gadtools.h> /* for BARLABEL in MenuItem */
-
- #include <exec/execbase.h>
-
- /* Prototypes */
- #ifdef __GNUC__
- #include <proto/alib.h>
- #endif
-
- #include <proto/muimaster.h>
- #include <proto/exec.h>
- #include <clib/alib_protos.h>
- #include <proto/dos.h>
-
- #include <stdlib.h>
-
- /* Stack size to run us with */
- LONG __stack=20000;
-
- /* Include GUI stuff */
- #include "PGP5GUI.h"
-
- /*
- ** Functions in PGP5GUI.c
- */
- extern struct ObjApp *CreateApp(void);
- extern void DisposeApp(struct ObjApp *);
-
- /*
- ** Functions in PGP5Interface.c
- */
- extern BOOL InitASLStuff(struct ObjApp *app);
- extern int init_resources(void);
- extern void free_resources(void);
- extern void PGPK_list(struct ObjApp *app);
- extern BOOL OpenConWin(struct ObjApp *app);
- extern void GetWinConfigs(void);
- extern void EncFileOrClip(struct ObjApp *app);
- extern void DecFileOrClip(struct ObjApp *app);
- extern void SigFileOrClip(struct ObjApp *app);
- extern void AddKeysFileOrClip(struct ObjApp *app);
-
- /*
- ** Functions in PGPEInterface.c
- */
- extern BOOL Do_Encryption(struct ObjApp *app);
-
- /*
- ** Functions in PGPVInterface.c
- */
- extern void Do_Decryption(struct ObjApp *app);
-
- /*
- ** Functions in PGPSInterface.c
- */
- extern void Do_Signing(struct ObjApp *app);
-
- /*
- ** Functions in PGPKInterface.c
- */
- extern void Do_ADD_KEYADD(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYCHECK(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYDISABLE(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYEDIT(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYREMOVE(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYREMSIG(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYREMUID(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYREVOKE(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYREVOKESIG(struct ObjApp *app);
- extern BOOL Do_EDIT_KEYSIGN(struct ObjApp *app, BOOL doID);
- extern void Do_MISC_KEYGEN(struct ObjApp *app);
- extern BOOL Do_MISC_KEYEXTRACT(struct ObjApp *app);
- extern BOOL Do_MISC_KEYLIST(struct ObjApp *app);
-
- /*
- ** Functions in FileReqPGP5.c
- */
- extern void Get_Encrypt_Name(struct ObjApp *app);
- extern void Get_Decrypt_Name(struct ObjApp *app);
- extern void Get_Sign_Name(struct ObjApp *app);
- extern void Get_KeysAdd_Name(struct ObjApp *app);
-
- /* Declarations for libraries (inserted by GenCodeC) */
- struct Library *IntuitionBase = NULL;
- struct Library *MUIMasterBase = NULL;
- struct Library *AslBase = NULL;
-
- int init(void);
- void end(void);
-
- /*
- ****************************************************************************************
- **
- ** The '__main()' function. We don't use command line or icon arguments.
- **
- ****************************************************************************************
- */
- void __stdargs __main(char *line)
- {
- struct ObjApp *App; /* Object */
- int running;
- ULONG signal;
-
- /* Program initialisation */
- running = init();
-
- /* Did we init (libraries) ok? */
- if (running != RETURN_OK)
- {
- end();
- exit(RETURN_FAIL);
- }
-
- /* Init our resources */
- running = init_resources();
-
- /* Did we init resources ok? */
- if (running != RETURN_OK)
- {
- PrintFault(IoErr(), "Can't init resources");
- end();
- exit(RETURN_FAIL);
- }
-
- /* Get output window and ASL Requester positions and dimensions */
- GetWinConfigs();
-
- /* Create Object */
- if (!(App = CreateApp()))
- {
- PrintFault(IoErr(), "Can't create PGP5GUI App");
- end();
- exit(RETURN_FAIL);
- }
-
- /* Open a window and connect a 'console' to it */
- if (!OpenConWin(App))
- {
- PrintFault(IoErr(), "Can't create console");
- end();
- exit(RETURN_FAIL);
- }
-
- /* Init ASL structure */
- if (!InitASLStuff(App))
- {
- PrintFault(IoErr(), "Can't allocate ASL");
- end();
- exit(RETURN_FAIL);
- }
-
- /* Get a key list */
- PGPK_list(App);
-
- /* We're OK to continue... */
- running = TRUE;
-
- /* The main running loop */
- while (running)
- {
- switch (DoMethod(App->App,MUIM_Application_Input,&signal))
- {
- case MUIV_Application_ReturnID_Quit:
- running = FALSE;
- break;
-
- /* Insert your code between the "case" statement and comment "end of case ..." */
- case Encrypt_DOIT:
- running = Do_Encryption(App);
- break;
- /* end of case Encrypt_DOIT */
-
- case Decrypt_DOIT:
- Do_Decryption(App);
- break;
- /* end of case Decrypt_DOIT */
-
- case Sign_DOIT:
- Do_Signing(App);
- break;
- /* end of case Sign_DOIT */
-
- case ADD_KEYADD:
- Do_ADD_KEYADD(App);
- break;
- /* end of case ADD_KEYADD */
-
- case EDIT_KEYCHECK:
- running = Do_EDIT_KEYCHECK(App);
- break;
- /* end of case EDIT_KEYCHECK */
-
- case EDIT_KEYDISABLE:
- running = Do_EDIT_KEYDISABLE(App);
- break;
- /* end of case EDIT_KEYDISABLE */
-
- case EDIT_KEYEDIT:
- running = Do_EDIT_KEYEDIT(App);
- break;
- /* end of case EDIT_KEYEDIT */
-
- case EDIT_KEYREMKEY:
- running = Do_EDIT_KEYREMOVE(App);
- break;
- /* end of case EDIT_KEYREMKEY */
-
- case EDIT_KEYREMSIG:
- running = Do_EDIT_KEYREMSIG(App);
- break;
- /* end of case EDIT_KEYREMSIG */
-
- case EDIT_KEYREMUID:
- running = Do_EDIT_KEYREMUID(App);
- break;
- /* end of case EDIT_KEYREMUID */
-
- case EDIT_KEYREVOKE:
- running = Do_EDIT_KEYREVOKE(App);
- break;
- /* end of case EDIT_KEYREVOKE */
-
- case EDIT_KEYREVSIG:
- running = Do_EDIT_KEYREVOKESIG(App);
- break;
- /* end of case EDIT_KEYREVSIG */
-
- case EDIT_KEYSIGN:
- running = Do_EDIT_KEYSIGN(App, FALSE);
- break;
- /* end of case EDIT_KEYSIGN */
-
- case EDIT_KEYSIGNKEY:
- running = Do_EDIT_KEYSIGN(App, TRUE);
- break;
- /* end of case EDIT_KEYSIGNKEY */
-
- case MISC_KEYGEN:
- Do_MISC_KEYGEN(App);
- break;
- /* end of case MISC_KEYGEN */
-
- case MISC_KEYEXTRACT:
- running = Do_MISC_KEYEXTRACT(App);
- break;
- /* end of case MISC_KEYEXTRACT */
-
- case MISC_KEYLIST:
- running = Do_MISC_KEYLIST(App);
- break;
- /* end of case MISC_KEYLIST */
-
- case MISC_KEYLIST_UPDATE:
- PGPK_list(App);
- break;
- /* end of case MISC_KEYLIST_UPDATE */
-
- case Pop_Enc_File:
- Get_Encrypt_Name(App);
- break;
- /* end of case Pop_Enc_File */
-
- case Pop_Dec_File:
- Get_Decrypt_Name(App);
- break;
- /* end of case Pop_Dec_File */
-
- case Pop_Sig_File:
- Get_Sign_Name(App);
- break;
- /* end of case Pop_Sig_File */
-
- case Pop_Keys_AddFile:
- Get_KeysAdd_Name(App);
- break;
- /* end of case Pop_Keys_AddFile */
-
- case Enc_FILE_CLIP:
- EncFileOrClip(App);
- break;
- /* end of case Enc_FILE_CLIP */
-
- case Decrypt_OUTTYPE:
- DecFileOrClip(App);
- break;
- /* end of case Decrypt_OUTTYPE */
-
- case Sig_FILE_CLIP:
- SigFileOrClip(App);
- break;
- /* end of case Sig_FILE_CLIP */
-
- case AddKeys_FILE_CLIP:
- AddKeysFileOrClip(App);
- break;
- /* end of case AddKeys_FILE_CLIP */
-
- /* End computing of IDCMP */
-
- default:
- break;
- }
-
- if (running && signal)
- Wait(signal);
- }
-
- /* Shut down the main App */
- DisposeApp(App);
-
- /* Free libraries */
- end();
-
- exit(running);
- }
-
- /**************************************************************************************/
-
- /*
- ** Init() function
- */
- int init(void)
- {
- int rc = RETURN_OK;
-
- if (!(IntuitionBase = OpenLibrary("intuition.library",37)))
- {
- PrintFault(IoErr(), "Can't Open Intuition Library");
- rc = RETURN_FAIL;
- }
- else
- {
- if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
- {
- PrintFault(IoErr(), "Can't Open MUIMaster Library");
- rc = RETURN_FAIL;
- }
- else
- {
- /* Open the ASL library */
- if (!(AslBase = OpenLibrary("asl.library", 37L)))
- {
- PrintFault(IoErr(), "Can't Open ASL Library");
- rc = RETURN_FAIL;
- }
- }
- }
-
- return(rc);
- }
-
- /*
- ** End() function
- */
- void end(void)
- {
- free_resources();
-
- if (AslBase)
- CloseLibrary(AslBase);
-
- if (MUIMasterBase)
- CloseLibrary(MUIMasterBase);
-
- if (IntuitionBase)
- CloseLibrary(IntuitionBase);
- }
-